package com.tanhua.dubbo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.pojo.Test;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface SoulTestMapper extends BaseMapper<Test> {

    @Select("SELECT * FROM (SELECT * FROM `tb_test` WHERE level=#{level}) t1 WHERE t1.id >= " +
            "floor(((SELECT MAX(id) FROM `tb_test` WHERE level=#{level})-(SELECT MIN(id) FROM `tb_test` WHERE level=#{level})) * RAND() + (SELECT MIN(id) FROM `tb_test` WHERE level=#{level})) LIMIT 1")
    Test findRandomTest(@Param("level") int level);
}
